use std::collections::HashMap;

pub fn goldbach_conjecture() -> u64 {
    let mut map = HashMap::new();
    let mut pri = Vec::new();
    let mut res = Vec::new();
    let mut num = 2;
    loop {
        if !map.contains_key(&num) {
            pri.push(num);
        } else if num % 2 == 1 {
            let mut i = 0;
            let mut flag = false;
            loop {
                if 2 * i * i >= num {
                    break;
                }
                if !map.contains_key(&(num - 2 * i * i)) {
                    flag = true;
                    break;
                }
                i += 1;
            }
            if !flag {
                res.push(num);
                if res.len() > 1 {
                    break;
                }
            }
        }
        for &p in pri.iter() {
            map.insert(p * num, true);
            if num % p == 0 {
                break;
            }
        }
        num += 1;
    }
    res[0] + res[1]
}
